<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<link rel="stylesheet" type="text/css" href="/static/css/hw-admin.css">
	<link rel="stylesheet" href="/static/css/lb.css"> 
    <style>
        #edui1_iframeholder,#edui1 {
            width: 853px !important;
        }
        #account-table input {
            width: 100%;
            height: 100%;
            border: none;
        }
        #allmap,#container {
            width: 500px;
            height: 250px;
        }
        .add-delete table th {
            background: #fff;
        }
        .delete-box .error {
            display: inline-block;
            width: 45px;
        }
    </style>
   	<!--[if lt IE 9]>
    　 <script src="https://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
       <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.js"></script>
    <![endif]-->
    <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=MEVBZ-TJGRJ-LF7F2-FUSW3-B6EYF-4IBDI"></script>
</head>
<body>

    <div class="hw-iframe">
        
        <!-- 顶部标题 -->
        <div class="hw-header-wrapper">
            <div class="hw-header">
                <div class="hw-header__item--left">
                    酒店主页
                </div> 
            </div>
        </div>
        <form action="" method="POST" id="main-form">
            <div class="hw-group">
                <div class="group-title">酒店介绍</div>
                <div class="group-info">
                    <div class="group-item">
                        <div class="hw-input-label" style="width: 100%;margin-bottom: 40px;position: relative;">
                            <div class="name">酒店logo</div>

                            <div class="form-control" style="width: 80%;">
                                <div class="hw-img-lists hw-img-logo">
                                 
                                    <?php if (!empty($find['logo'])): ?>
                                        <div class="list">
                                            <img src="<?=$find['logo'] ?>" alt="">
                                            <div class="operate">
                                                <i class="iconfont preview-img">&#xe615;</i>
                                                <i class="iconfont delete-img">&#xe65f;</i>
                                            </div>
                                            <input type="hidden" name="logo" value="<?=$find['logo'] ?>">
                                            <div class="musk"></div>
                                        </div>
                                        <label for="img-input" class="add-img-btn add-img-logo" style="display: none">+</label>
                                    <?php else: ?>
                                        <label for="img-input" class="add-img-btn add-img-logo">+</label>
                                    <?php endif ?>
                                  
                                    <span style="position: absolute;bottom: -60px;left: 110px;color: #ccc;" class="tip">推荐尺寸(144px * 144px)</span>
                                </div>
                            </div>
                        </div> 
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label" style="width: 100%;margin-bottom: 40px;position: relative;">
                            <div class="name">酒店品牌图</div>

                            <div class="form-control" style="width: 80%;">
                                <div class="hw-img-lists hw-img-banner">
                                 
                                    <?php if (!empty($find['banner'])): ?>
                                        <div class="list">
                                            <img src="<?=$find['banner'] ?>" alt="">
                                            <div class="operate">
                                                <i class="iconfont preview-img">&#xe615;</i>
                                                <i class="iconfont delete-img">&#xe65f;</i>
                                            </div>
                                            <input type="hidden" name="banner" value="<?=$find['banner'] ?>">
                                            <div class="musk"></div>
                                        </div>
                                        <label for="img-input" class="add-img-btn add-img-banner" style="display: none">+</label>
                                    <?php else: ?>
                                        <label for="img-input" class="add-img-btn add-img-banner">+</label>
                                    <?php endif ?>
                                       
                                    <span style="position: absolute;bottom: -60px;left: 110px;color: #ccc;" class="tip">推荐尺寸(1200px * 350px),在用户认证页面显示</span>
                                  
                                </div>
                            </div>
                        </div> 
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label" style="width: 100%;margin-bottom: 40px;position: relative;">
                            <div class="name">封面图</div>

                            <div class="form-control" style="width: 80%;">
                                <div class="hw-img-lists hw-img-img">
                                    <?php if (!empty($find['img'])): ?>
                                    <?php foreach ($find['img'] as $key => $value): ?>
                                        <div class="list">
                                            <img src="<?=$value ?>" alt="">
                                            <div class="operate">
                                                <i class="iconfont preview-img">&#xe615;</i>
                                                <i class="iconfont delete-img">&#xe65f;</i>
                                            </div>
                                            <input type="hidden" name="img[]" value="<?=$value ?>">
                                            <div class="musk"></div>
                                        </div>
                                       
                                    <?php endforeach ?>
                                        <label for="img-input" class="add-img-btn add-img-img" style="display: <?=count($find['img']) == 15 ? 'none' : 'block'; ?>">+</label>
                                    <?php else: ?>
                                        <label for="img-input" class="add-img-btn  add-img-img">+</label>
                                    <?php endif ?>
                                    <span style="position: absolute;bottom: -60px;left: 110px;color: #ccc;" class="tip">推荐尺寸(1200px * 360px)</span>
                                </div>
                            </div>
                        </div> 
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label">
                            <div class="name">酒店名称<span>*</span></div>
                            <div class="form-control">
                                <input class="hw-input" type="text" name="name" value="<?=$find['name'] ?>" required>
                            </div>
                        </div>
                        <div class="hw-input-label">
                            <div class="name">联系电话<span>*</span></div>
                            <div class="form-control">
                                <input class="hw-input" iscontact="iscontact" type="text" name="phone" value="<?=$find['phone'] ?>" required>
                            </div>
                        </div>
                    </div>

                    <div class="group-item">                    
                        <div class="hw-input-label">
                            <div class="name">酒店地址</div>
                            <div class="form-control" style="width: 360px;">
                                <select id="province" class="hw-input smaller-size" name="province"></select>
                                <select id="city" class="hw-input smaller-size" name="city"></select>
                                <select id="area" class="hw-input smaller-size" name="area"></select>
                            </div>
                        </div>
                        <div class="hw-input-label">
                            <div class="form-control">
                                <input class="hw-input address_detail" type="text" name="address" value="<?=$find['address'] ?>" required>
                            </div>
                        </div>
                        <div style="min-width: 83px;cursor: pointer;" onclick="searchByStationName()" class="hw-btn--normal map-btn">
                            地图定位
                        </div>
                    </div>
                    <div class="group-item">                    
                        <div class="hw-input-label">
                            <div class="name"></div>
                            <div class="form-control" id="allmap">
                                
                            </div>
                        </div>
                    </div>
                    <div style="display: none;" class="group-item">
                        <div class="hw-input-label">
                            <div class="name">酒店经度</div>
                            <div class="form-control">
                                <input class="hw-input" onmousewheel="stopScrollFun"  onDOMMouseScroll="stopScrollFun" type="number" id="lng" name="long" value="<?=$find['long'] ?>">
                            </div>
                        </div>
                        <div class="hw-input-label">
                            <div class="name">酒店维度</div>
                            <div class="form-control">
                                <input class="hw-input" id="lat" type="number" name="lat" value="<?=$find['lat'] ?>">
                            </div>
                        </div>
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label">
                            <div class="name">酒店星级</div>
                            <div class="form-control">
                                <input class="hw-input" type="text" name="star_level" value="<?=$find['star_level'] ?>">
                            </div>
                        </div>
                        <div class="hw-input-label">
                            <div class="name">房间数量</div>
                            <div class="form-control">
                                <input class="hw-input" type="number" name="room_num" value="<?=$find['room_num'] ?>">
                            </div>
                        </div>
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label">
                            <div class="name">房间单价</div>
                            <div class="form-control">
                                <label class="hw-select">
                                    <input class="hw-input" name="room_price" type="text" value="<?=$find['room_price'] ?>" readonly="" unselectable="on">
                                    <div class="select-options">
                                        <div class="option <?=$find['room_price'] == '600~800' ? 'selected' : '' ?>" data-value="600~800"><span>600~800</span><i class="iconfont">&#xe649;</i></div>
                                        <div class="option <?=$find['room_price'] == '801~1000' ? 'selected' : '' ?>" data-value="801~1000"><span>801~1000</span><i class="iconfont">&#xe649;</i></div>
                                        <div class="option <?=$find['room_price'] == '1001~1500' ? 'selected' : '' ?>" data-value="1001~1500"><span>1001~1500</span><i class="iconfont">&#xe649;</i></div>
                                        <div class="option <?=$find['room_price'] == '1501~2000' ? 'selected' : '' ?>" data-value="1501~2000"><span>1501~2000</span><i class="iconfont">&#xe649;</i></div>
                                        <div class="option <?=$find['room_price'] == '2000以上' ? 'selected' : '' ?>" data-value="2000以上"><span>2000以上</span><i class="iconfont">&#xe649;</i></div>
                                    </div>
                                <div class="show-option"><?=$find['room_price'] ?></div><i class="iconfont"></i></label>
                            </div>
                        </div>
                    </div>
                    <div class="group-item">
                        <div class="hw-input-label">
                            <div class="name">酒店介绍</div>
                            <div class="form-control">
                                <script id="editor-container" name="info" required type="text/plain"><?=$find['info'] ?></script>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="group-title">设施服务<span class="add-service">新增</span></div>
                <div class="hotel-content">
                    <?php if (!empty($find['service'])): ?>
                    <?php foreach ($find['service'] as $key => $value): ?>
                        <div class="delete-box">
                            <div class="group-title s-title"><input type="text" data-num="<?=$key ?>" name="service[<?=$key ?>][name]" value="<?=$value['name'] ?>" readonly required><span class="s-editlist">编辑</span><span class="s-delete">删除</span></div>
                            <div class="s-content">
                                <?php if (isset($value['class'])): ?>
                                <?php foreach ($value['class'] as $val): ?>
                                    <div class="item"><?=$val ?><span><i class="i-delete iconfont">&#xe892;</i></span><input type="hidden" value="<?=$val ?>" name="service[<?=$key ?>][class][]"></div>
                                <?php endforeach ?>
                                <?php endif ?>
                                <div class="item add-item">添加</div>
                            </div>
                        </div>  
                    <?php endforeach ?>
                    <?php endif ?>
                </div>
                <div class="group-title">交通信息</div>
                <div class="group-info"> 
                    <div class="main-table-wrap add-delete" style="width: 40%;">
                        <table cellspacing="0" cellpadding="0" border="0">  
                            <colgroup>
                                <col class="col-5">
                                <col class="col-5">
                                <col class="col-5">
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>地点名称</th>
                                    <th>距离</th>
                                    <th class="blue-color add-table">新增</th>
                                </tr>
                            </thead>

                            <tbody>
                                <?php if (!empty($find['traffic'])): ?>
                                <?php foreach ($find['traffic'] as $key => $value): ?>
                                    <tr>
                                        <td><input name="traffic[<?=$key ?>][name]" type="text" value="<?=$value['name'] ?>"></td>
                                        <td><input name="traffic[<?=$key ?>][distance]" type="text" value="<?=$value['distance'] ?>"></td>
                                        <td>
                                            <a class="red-color" href="javascript::"><i class="iconfont" style="margin-right: 3px;">&#xe65f;</i>删除</a>
                                        </td>
                                    </tr>
                                <?php endforeach ?>
                                <?php endif ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="group-operate" style="background: #fff;">
				<div class="hw-container">
					<a class="hw-btn hw-default-btn" href="">取消</a>
					<button class="hw-btn">保存</button>
				</div>
			</div>
        </form>
    </div>

	<script src="/static/lib/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="/static/lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="/static/lib/jquery.form.min.js"></script>
    <script type="text/javascript" src="/static/js/common/util.js"></script>
	<script type="text/javascript" src="/static/js/common/upload.js"></script>
	<script type="text/javascript" src="/static/lib/jquery.validate.js"></script>
	<script type="text/javascript" src="/static/lib/messages_zh.js"></script>
	<script type="text/javascript" src="/static/js/common/validateExtend.js"></script>
	<script type="text/javascript" src="/static/js/common/common.js"></script>
    <script type="text/javascript" src="/static/js/PCASClass.js"></script>
    <script type="text/javascript" src="/static/lib/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="/static/lib/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" src="/static/lib/ueditor/addCustomizeDialog.js"></script>
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.10&key=fdfdefb18594af02bbb294b624770982"></script> 
    <script type="text/javascript" src="/static/js/HotelAdmin/index.js"></script>
    <script type="text/javascript">
    // var cpLock = false;
    // txtNote.addEventListener('compositionstart', function(){
    //     cpLock = true;
    // })
    // txtNote.addEventListener('compositionend', function(){
    //     cpLock = false;
    // })
    // txtNote.addEventListener('input', function(){
    //     wordsLimit(this);
    // });
 

    var num_one = <?=count($find['service']) ?>;
    var num_two = <?=count($find['traffic']) ?>;
        $('.add-service').on('click',function(){
            var str  =  '<div class="delete-box">'+
                        '<div class="group-title s-title"><input data-num="'+ num_one +'" name="service['+ num_one +'][name]" type="text" value="" required><span class="s-editlist">编辑</span><span class="s-delete">删除</span></div>'+
                        '<div class="s-content">'+
                            '<div class="item add-item">添加</div>'+
                        '</div>'+
                    '</div>';
            $('.hotel-content').append(str); 
            $('.hotel-content').find('.delete-box:last-child').find('.s-title input').focus();
            $('.hotel-content').find('.delete-box:last-child').find('.s-title input').on('blur',function(){
               $(this).val($(this).val().substr(0,7));
           })
            num_one = num_one + 1;
        })
        $('.hw-group').on('click','.s-editlist',function(){
            $(this).parent().find('input').removeAttr('readonly').focus();
            $(this).parent().find('input').on('blur',function(){
                $(this).val($(this).val().substr(0,7));
            })
        })
        $('.hw-group').on('click','.s-delete',function(){
            $(this).parents('.delete-box').remove();
        })
        $('.hw-group').on('click','.add-item',function(){
            var _this = $(this);
            $(this).html('<input type="text">');
            $(this).parent().find('input').focus();
            $(this).addClass('blue');
            $(this).parent().find('input').on('blur',function(){
                // num_two = ++num_two;
                var value = $(this).val().substr(0,7);
                if(value==''){
                    var str =  '<div class="item add-item">添加</div>';
                    _this.parent().append(str);
                    _this.remove();
                    return;
                }
                
                var str =  '<div class="item add-item">添加</div>';
                var dataNum = $(this).parents('.delete-box').find('.s-title input').data('num');
                _this.html(value+'<span><i class="i-delete iconfont">&#xe892;</i></span>'+'<input type="hidden" value="'+ value +'" name="service['+ dataNum +'][class][]" required>');
                $(this).remove();
                _this.removeClass('add-item');
                _this.parent().append(str);
               
            })
            // $(this).parent().find('input').on('blur',function(){
            //     var value = $(this).val();
               
            // })
        })
        $('.hw-group').on('click','.i-delete',function(){
            $(this).parents('.item').remove();
        })
        $('.add-table').on('click',function(){
            var str =   '<tr>'+
                            '<td><input name="traffic['+ num_two +'][name]" type="text" required></td>'+
                            '<td><input name="traffic['+ num_two +'][distance]" type="text" required></td>'+
                            '<td>'+
                                '<a class="red-color" href="javaScript:;"><i class="iconfont" style="margin-right: 3px;">&#xe65f;</i>删除</a>'+
                            '</td>'+
                        '</tr>';
            $('.add-delete tbody').append(str);
            $('.add-delete tbody').find('tr:last-child').find('td:first-child').find('input').focus()
            num_two = num_two + 1;
        })
        $('.add-delete').on('click','.red-color',function(){
            $(this).parents('tr').remove();
            // $.confirm({
            //     msg: '确定删除？',
            //     confirm: function(){
            //         $.get(`/Admin/Student/del_student/${id}`,function(info){
            //             info = JSON.parse(info);
            //             if(info.code==1) {
            //                 $.alert('删除成功');
            //                 $(this).parents('tr').remove();
            //             }else {
            //                 $.alert(info.msg);
            //             }
            //         })
            //     }
            // })
        }) 

     
    
    </script>
    <script>
        var init = function(latitude,longitude) {
            var center = new qq.maps.LatLng( latitude,longitude);
            var map = new qq.maps.Map(document.getElementById('allmap'),{
                center: center,
                zoom: 15
            });
            //创建marker
            var marker = new qq.maps.Marker({
                position: center,
                map: map
            });
        }
        if($("#lng").val()&&$("#lat").val()){//编辑
            longitude = $("#lng").val();
            latitude = $("#lat").val();
            console.log(longitude,latitude)
   
            init(latitude,longitude);
        }
        else{//添加
            $.ajax({  
                type : "post",  //提交方式  
                url : "/Api/QQMap/location",  
                data : {}, 
                success : function(res) {
                    var res = JSON.parse(res);
                    if(res.code == '1'){
                    init(res.lat,res.long); 
                    }
                    else{
                    alert("本地地址获取失败");
                    }
                }
            })          
        }    
        function searchByStationName() {

   
            if($("#province option:selected").text()=="请选择省份"){
                $.alert("请选择省份");
                return;
            }
            if($("#city option:selected").text()=="请选择城市"){
                $.alert("请选择城市");
                return;
            }
            if($("#area option:selected").text()=="请选择地区"){
                $.alert("请选择地区");
                return;
            }
            if($(".address_detail").val()==""){
                $.alert("请填写详细地址");
                return;
            }
            var keyword =$("#province option:selected").text()+$("#city option:selected").text()+$("#area option:selected").text()+$('.address_detail').val();
            $.post("/Api/QQMap/geocoder", {address: keyword},
                function (data) {
                    data = JSON.parse(data);
                    console.log(data);
                    longitude = data.long;
                    latitude = data.lat;
                    $("#lng").val(longitude);
                    $("#lat").val(latitude);
                    init(latitude,longitude);
                }
            );

               

    }
    var provinceval = '<?=!empty($find['province'])?$find['province']:'请选择省份'?>';
    var cityval = '<?=!empty($find['city'])?$find['city']:'请选择城市'?>';
    var area = '<?=!empty($find['area'])?$find['area']:'请选择地区'?>';
    // 省市区联动
   
    // var provinceval = '请选择省份';
    // var cityval = '请选择城市';
    // var area = '请选择地区';
    new PCAS("province","city",'area',provinceval,cityval,area);
    </script>
</body>
</html>